﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Text;
using WebToolRepository;
using WebToolService;

namespace WebToolService
{
    public class ServiceBase<TMainRepository, TTableName> where TMainRepository : class, new()
    {
        #region Properties

        private WebToolDBEntities _context = null;
        public virtual WebToolDBEntities Context
        {
            get
            {
                _context = _context ?? new WebToolDBEntities();
                return _context;
            }
        }
        public virtual List<TTableName> Query { get; set; }
        public virtual TMainRepository Main { get; set; }
        public virtual int Count { get; set; }

        #endregion
        #region Constructors
        public ServiceBase()
        {
            Main = new TMainRepository();
        }
        #endregion
        #region Methods
        public void CommitChanges()
        {
            Context.SaveChanges();
        }

        #endregion
    }
}
